package com.klangner.lucene.index
{
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;
	
	import flexunit.framework.TestCase;
	
  public class SegmentTest extends TestCase {
  	
  	private var _fileStream:FileStream = new FileStream();
  	
  	
    public function testFormat():void {
   		assertEquals(SegmentFormat.FORMAT_HAS_PROX, getSegments().getFormat());
   		
   		closeStream();
    }

    public function testSegment():void {
   		
   		var segments:Segments = getSegments();
   		var segment:Segment;
   		
   		assertEquals(1, segments.getSize());
   		segment = segments.getSegment(0);
   		assertNotNull(segment);
   		
   		closeStream();
    }

    

    // ------------------------------------------------------------------------
    private function getSegments():Segments {
   		var file:File = File.applicationDirectory.resolvePath("test-data/index/segments_2");
   		_fileStream.open(file, FileMode.READ);
   		return new Segments(_fileStream);
    }
    
    private function closeStream():void {
   		_fileStream.close();
    }
  }
}